package cn.iocoder.yudao.module.ai.dal.mysql.material;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.ai.dal.dataobject.material.MaterialDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.ai.controller.admin.material.vo.*;

/**
 * 素材管理 Mapper
 *
 * @author 侯俊青
 */
@Mapper
public interface MaterialMapper extends BaseMapperX<MaterialDO> {

    default PageResult<MaterialDO> selectPage(MaterialPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MaterialDO>()
                .likeIfPresent(MaterialDO::getName, reqVO.getName())
                .eqIfPresent(MaterialDO::getDescription, reqVO.getDescription())
                .eqIfPresent(MaterialDO::getSourceType, reqVO.getSourceType())
                .eqIfPresent(MaterialDO::getFileType, reqVO.getFileType())
                .eqIfPresent(MaterialDO::getOwnerOrg, reqVO.getOwnerOrg())
                .likeIfPresent(MaterialDO::getOwnerOrgName, reqVO.getOwnerOrgName())
                .eqIfPresent(MaterialDO::getSenceType, reqVO.getSenceType())
                .likeIfPresent(MaterialDO::getFileOriginalName, reqVO.getFileOriginalName())
                .eqIfPresent(MaterialDO::getFileUploadPath, reqVO.getFileUploadPath())
                .eqIfPresent(MaterialDO::getDuration, reqVO.getDuration())
                .eqIfPresent(MaterialDO::getContainFileNum, reqVO.getContainFileNum())
                .eqIfPresent(MaterialDO::getFileSize, reqVO.getFileSize())
                .eqIfPresent(MaterialDO::getRepairStatus, reqVO.getRepairStatus())
                .betweenIfPresent(MaterialDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(MaterialDO::getCreateTime, reqVO.getCreateTimeBegin(), reqVO.getCreateTimeEnd())
                .eqIfPresent(MaterialDO::getSuplierId, reqVO.getSuplierId())
                .eqIfPresent(MaterialDO::getCreator, reqVO.getCreator())
                .orderByDesc(MaterialDO::getId));
    }

}